<?php session_start();


 echo "<div class='wrapper'>";
 echo "<div class='header'>";
 echo "<a href='index.php' id='image'><img src='images/logo.png' alt='title' height='50'/></a> ";
 echo "<h1>RERGag - Just For Laugh</h1>";            
 echo "<div class='searchhead'>";
 echo "<form method='post' action='search.php'>";
 echo "<p> Search Posts!</p>";
 echo "<p> Search : <input type='text' name='searchform'/>"; 
 echo "<input type='submit' value='Search' /> <br/>";
 echo "<input type='checkbox' name='byuser' value='byuser'/> by user_name";
 echo "<input type='checkbox' name='bytitletag' value='byjudultag'/> by content title and tag";
 echo "</p>";
 echo "</form>";
 echo "</div>";
 echo "<div class='loginhead' id='loghead'>";
$user_name = $_SESSION['user_name'];
$query = "select avatar from user where user_name ='$user_name' ";
$hasil = mysql_query($query);
global $avatar;
while ($row1= mysql_fetch_array($hasil)){
    $avatar = $row1['avatar'];
}
if($_SESSION['login'] == true)
                    {
                        echo '<form action="logout.php"> ';
                        echo "<a href='profile.php' id='ava'>Your Avatar</a><img src='".$avatar."' height=50px;/> ";
                        echo "Welcome, ".$_SESSION['user_name']."!<br>";
                        echo '<input type="submit" value="Logout">';
                        echo '</form>';
                    }
                    else
                    {
                        echo '<form>';
                        echo '<p>Already Registered? Login is just a step away!</p>';
                        echo '<p> user_name : <input type="text" id="usr" cols="1" rows="1" width =100 height =  100 /> </p>';
                        echo '<p> Password : <input type="password" id="pass" cols="1" rows="1" width =100" height =  100"/> </p>';
                        echo '<input type="button" value="Login" onclick="demiValidate()" />';
                        echo '</form>';
                    }
 echo"<div class='links'>";
 echo"<ul>";
 
 if($_SESSION['page'] != "registrasi")
    {    
        echo"          <li><a href='register.php' id='registrasi_link'>Registrasi</a></li>";
    }
 else
    {
        echo"          <li><a href='register.php' id='registrasi_link' class='active'>Registrasi</a></li>";
    }
 
 if($_SESSION['page'] != "index")
    {
        echo" <li><a href='index.php' id='home_link'>Home</a></li>"; 
    }
 else
    {
        echo"          <li><a href='index.php' id='home_link' class='active'>Home</a></li>";
    }

 if($_SESSION['page'] != "konten")
    {
        echo" <li><a href='konten.php' id='daftar_link'>Konten</a></li>";
    }
 else 
    {
            echo" <li><a href='konten.php' id='daftar_link' class='active'>Konten</a></li>";
    }
 
 if($_SESSION['login'] == true && $_SESSION['page'] != "posting")
    {
        echo "<li><a href='posting.php' id='upload_link' >Posting</a></li>";
    }
 else
    {
        echo "<li><a href='posting.php' id='upload_link' class='active'>Posting</a></li>";
    }
 
 echo "</ul>";
 echo "</div>";             
 
 echo "<script type='text/javascript'>";
 echo "function demiValidate() ";
 echo "{var user = document.getElementById('usr').value;
        var pass = document.getElementById('pass').value;
                      validator(user,pass);}";
                 
echo "</script>";
echo "<script type='text/javascript' src='script/validator.js'></script>";
echo "</div></div></div>"                
                            
?>
